/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-07-27
 * Time: 22:14
 */
import java.util.Scanner;
public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数:");
        int n = scanner.nextInt();
        int ret = fact(n);
        System.out.println(n+"的阶乘为："+ret);
        int sum = factsum(n);
        System.out.println(n+"的阶乘和为"+sum);
    }
    public static int factsum(int n) { //计算N的阶乘和
        int sum = 0;
        while (n != 0) {
            sum += fact(n);
        }
        return sum;
    }
    public static int fact (int n){ //计算N的阶乘
        int ret = 1;
        while (n != 0) {
            ret *= n;
            n--;
        }
        return ret;
    }
        public static void main2(String[] args) { //求最大值
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输出两个数：");
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int ret = max(a,b);
            System.out.println(a+"和"+b+"的较大值为"+ret);
            System.out.println("请在输入一个数");
            int c = scanner.nextInt();
            int ret1 = max(a,b,c);
            System.out.println(a+"和"+b+"和"+c+"的最大值为"+ret1);

        }
        public static int max (int x,int y) { //求两个数的最大值
            return (x > y ? x: y);
        }
        public static int max(int x,int y,int z) { //求三个数的最大值
            //return (max(max(x,y),z));
            int temp=max(x,y);
            return max(temp,z);
        }
        public static void main1(String[] args) {   //打印自幂数
//153 = 1^3 + 5^3 + 3^3
            for (long i = 0; i < 9999999; i++) {
                int count = 0;//计算当前i 有几位数
                long tmp = i;
                while (tmp != 0) {
                    count++;
                    tmp = tmp / 10;
                }
//count的值 是多少已经计算完成   i还是没有变的
//计算i[tmp]的每一位
                tmp = i;
                int sum = 0;
                while(tmp!=0) {
                    sum+=(int)Math.pow(tmp%10,count);
                    tmp/=10;
                }
                if(sum==i) {
                    switch (count) {
                        case 1:
                            System.out.println(i+"是独身数");
                            break;
                        //case 2:
                        //System.out.println(i+"是");
                        //
                        case 3:
                            System.out.println(i+"是水仙花数");
                            break;
                        case 4:
                            System.out.println(i+"是四叶玫瑰数");
                            break;
                        case 5:
                            System.out.println(i+"是五角星数");
                            break;
                        case 6:
                            System.out.println(i+"是六合数");
                            break;
                        case 7:
                            System.out.println(i+"是北斗七星数");
                            break;
                    }
                }
            }
        }
    }

